{% extends "base.html" %}

{% block content %}
<div class="card">
    <div class="card-header d-flex justify-content-between align-items-center">
        <h4>火车票详情 - {{ ticket.train_number }}</h4>
        <div>
            <a href="{{ url_for('edit_train_ticket', id=ticket.TrainRecordID) }}" class="btn btn-warning btn-sm">编辑</a>
            <form action="{{ url_for('delete_train_ticket', id=ticket.TrainRecordID) }}" method="POST" class="d-inline">
                <button type="submit" class="btn btn-danger btn-sm" onclick="return confirm('确定删除这张火车票吗？')">删除</button>
            </form>
        </div>
    </div>
    <div class="card-body">
        <div class="row">
            <div class="col-md-6">
                <table class="table table-bordered">
                    <tr>
                        <th width="30%">车次</th>
                        <td>{{ ticket.train_number }}</td>
                    </tr>
                    <tr>
                        <th>出发站</th>
                        <td>{{ ticket.departure_station }}</td>
                    </tr>
                    <tr>
                        <th>到达站</th>
                        <td>{{ ticket.arrival_station }}</td>
                    </tr>
                    <tr>
                        <th>出发时间</th>
                        <td>{{ ticket.departure_date }} {{ ticket.departure_time }}</td>
                    </tr>
                    <tr>
                        <th>到达时间</th>
                        <td>{{ ticket.arrival_date }} {{ ticket.arrival_time }}</td>
                    </tr>
                    <tr>
                        <th>席别</th>
                        <td>
                            {% if ticket.ticket_class == 'business' %}商务座
                            {% elif ticket.ticket_class == 'first' %}一等座
                            {% elif ticket.ticket_class == 'second' %}二等座
                            {% elif ticket.ticket_class == 'hard' %}硬座
                            {% elif ticket.ticket_class == 'soft' %}软座
                            {% elif ticket.ticket_class == 'hard_sleeper' %}硬卧
                            {% elif ticket.ticket_class == 'soft_sleeper' %}软卧
                            {% elif ticket.ticket_class == 'none' %}无座
                            {% else %}{{ ticket.ticket_class }}{% endif %}
                        </td>
                    </tr>
                </table>
            </div>
            <div class="col-md-6">
                <table class="table table-bordered">
                    <tr>
                        <th width="30%">座位号</th>
                        <td>{{ ticket.seat_number or '无' }}</td>
                    </tr>
                    <tr>
                        <th>票价</th>
                        <td>¥{{ ticket.price }}</td>
                    </tr>
                    <tr>
                        <th>里程</th>
                        <td>{{ ticket.distance or '未知' }} 公里</td>
                    </tr>
                    <tr>
                        <th>执行路局</th>
                        <td>{{ ticket.railwaycom or '未知' }}</td>
                    </tr>
                    <tr>
                        <th>车型</th>
                        <td>{{ ticket.train_model or '未知' }}</td>
                    </tr>
                    <tr>
                        <th>车号</th>
                        <td>{{ ticket.train_code or '未知' }}</td>
                    </tr>
                </table>
            </div>
        </div>
        
        {% if ticket.ticket_photo %}
        <div class="mt-4">
            <h5>车票照片</h5>
            <img src="data:image/jpeg;base64,{{ ticket.ticket_photo }}" class="img-fluid" style="max-height: 400px;">
        </div>
        {% endif %}
        
        <div class="mt-3">
            <a href="{{ url_for('train_tickets') }}" class="btn btn-secondary">返回列表</a>
        </div>
    </div>
</div>
{% endblock %}